﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ComponentModel.Composition;
using Kooboo.Domain;

namespace Kooboo.Commerce.Repositories
{
    [Export(typeof(IEntityUpdateCommand<IPromotionRule>))]
    public class PromotionRuleUpdateCommand:EntityUpdateCommand<IPromotionRule>
    {

        protected override string TableName
        {
            get { return "PromotionRule"; }
        }

        protected override string BuildCondition()
        {
            var ids = this.EntitySet.Select(i => i.Id.ToString()).ToArray();

            if (ids.Length == 0)
            {
                return " 1=2 ";
            }
            else
            {
                return " id in (" + string.Join(",", ids) + ") ";
            }
        }
    }
}
